package com.martin.dsc.mine;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Order {
    private String orderId;
    private String userId;
    private List<Item> items;
    private OrderStatus status;
    private LocalDateTime createTime;

    public Order(OrderBuilder builder) {
        this.orderId = builder.orderId;
        this.userId = builder.userId;
        this.items = builder.items;
        this.status = builder.status;
        this.createTime = builder.createTime;
    }

    public static class OrderBuilder {
        private String orderId;
        private String userId;
        private List<Item> items;
        private OrderStatus status;
        private LocalDateTime createTime;

        public OrderBuilder setOrderId(String orderId) {
            this.orderId = orderId;
            return this;
        }

        public OrderBuilder setUserId(String userId) {
            this.userId = userId;
            return this;
        }

        public OrderBuilder setItems(List<Item> items) {
            this.items = items;
            return this;
        }

        public OrderBuilder setStatus(OrderStatus status) {
            this.status = status;
            return this;
        }

        public OrderBuilder setCreateTime(LocalDateTime createTime) {
            this.createTime = createTime;
            return this;
        }

        public Order build() {
            return new Order(this);
        }
    }
}
